package cn.longge.mapper;

import cn.longge.entity.SysArea;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface SysAreaMapper extends Mapper<SysArea> {

    @SelectProvider(type = SysAreaSqlProvider.class,method = "selectByPage")
    List<SysArea> selectByPage(Map<String,Object> params);

    @Update("update sys_area set parent_ids = REPLACE(parent_ids,#{oldParentIds},#{parentIds}) " +
            "where parent_ids like concat('%,',#{id},',%');")
    int updateParents(SysArea area);

    @SelectProvider(type = SysAreaSqlProvider.class,method = "insertMany")
    void insertMany(@Param("areas") List<SysArea> areas);
}